package me.fung.wubi.worker.builder

import me.fung.wubi.worker.builder.BaseTableBuilder
import me.fung.wubi.base.define.table.CodeTable
import me.fung.wubi.worker.builder.BuildConfig
import me.fung.wubi.worker.builder.FileResources

class SimpleTableBuilder : BaseTableBuilder() {
    override fun build(content: FileResources.Content, buildConfig: BuildConfig): CodeTable {
        val result = CodeTable()
        //  1. 简码
        result.addTables(content.shortCodeTables)
        //  2. 普通
        if (buildConfig.autoShort) {
            result.addTableAutoShort(content.simpleTable)
        } else {
            result.addTable(content.simpleTable)
        }
        //  3. 词组(可选)
        if (!buildConfig.single) {
            result.addTables(content.groupTables)
        }
        //  4. 生僻字
        result.addTables(content.rareTables)
        if (buildConfig.fullCodeOrShort) {
            //  5. 简码字的全码
            result.addTable(content.shortFullCodeTable)
        }
        return result
    }
}